<%@ page language="java" import="com.sap.mw.jco.IFunctionTemplate" pageEncoding="UTF-8" %>
<%@ page import="com.sap.mw.jco.JCO" %>
<%@ page import="com.weaver.integration.datesource.SAPInterationOutUtil" %>
<%@ page import="com.weaver.integration.log.LogInfo" %>
<%@ page import="weaver.common.DateUtil" %>
<%@ page import="weaver.conn.BatchRecordSet" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%--获取流水号--%>
<%
    String curYear = DateUtil.getYear();
    out.print( ">>>>WeaSynSapCronJob>>>>>curYear="+curYear+"<br/>" );
    BatchRecordSet batchRecordSet = new BatchRecordSet();
    SAPInterationOutUtil outUtil = new SAPInterationOutUtil();
    JCO.Client myConnection = (JCO.Client)outUtil.getConnection("1", new LogInfo());
    myConnection.connect();
    // 实例名
    JCO.Repository myRepository = new JCO.Repository("Repository",myConnection);
    //设置BAPI函数
    IFunctionTemplate ft = myRepository.getFunctionTemplate("ZCO_ORDER_BUDGET");
    JCO.Function bapi = ft.getFunction();
    //输入参数和结构处理
    JCO.ParameterList input = bapi.getImportParameterList();
    input.setValue( "2022","P_GJAHR");
    input.setValue( "1","P_PERAB");
    input.setValue( "12","P_PERBI");
    input.setValue( "USD","P_WAERS");
    //输入表的处理
    JCO.ParameterList inputtable = bapi.getTableParameterList();
    JCO.Table t1 = inputtable.getTable("IT_FILE");
    t1.appendRow();
    t1.setValue("BL00010", "AUFNR");
    t1.setValue("6602141201", "KSTAR");
    t1.setValue("100", "WKG001");
    t1.setValue("0.00", "WKG002");
    t1.setValue("0.00", "WKG003");
    t1.setValue("213.92", "WKG004");
    t1.setValue("0.00", "WKG005");
    t1.setValue("0.00", "WKG006");
    t1.setValue("0.00", "WKG007");
    t1.setValue("0.00", "WKG008");
    t1.setValue("0.00", "WKG009");
    t1.setValue("0.00", "WKG010");
    t1.setValue("0.00", "WKG011");
    t1.setValue("0.00", "WKG012");
    //执行函数
    myConnection.execute(bapi);
    //输出参数和结构处理
    //JCO.ParameterList outPrint = bapi.getExportParameterList();
    //输出表的处理
    JCO.ParameterList Table00 = bapi.getTableParameterList();
    //返回处理结果以及日志
    Map<String, String> mapreturn = new HashMap<>();
    JCO.Table t = Table00.getTable("IT_RETURN");
    String ZFLAG = (String) t.getValue("ZFLAG");
    String OBJET = (String) t.getValue("OBJET");
    String MSG = (String) t.getValue("MSG");
    mapreturn.put("ZFLAG",ZFLAG);
    mapreturn.put("OBJET",OBJET);
    mapreturn.put("MSG",MSG);
    out.println("返回结果："+ mapreturn.toString());
    JCO.releaseClient(myConnection);
%>
<%!
public static boolean hasRepeatData(String wybs){
    RecordSet rs = new RecordSet(  );
    rs.executeQuery("select count(id) from uf_yssjje where wybs=?",wybs);
    rs.next();
    int counts = Util.getIntValue( rs.getString(1) );
    return counts<=0?true:false;
}
%>